<%#
    Auth: Wen
    Version: V1.0
    Data: 2019.8.20
    Function:
%>
<%+header%>
<html>
    <head>
    <meta charset="utf-8">
    <title>Wen</title>
    <script type="text/javascript">
    var XHR1 = new XHR();
    var testTemp = "";
    function checkLeave()
    {
        return "Leave?";
    }
    
    function TestLog(tmp, str)
    {
        tmp = tmp + str + "\n"; 
        return tmp;
    }
    /* 定时刷新返回结果 */
    function Refresh()
    {
        //2s刷新一次测试结果
        //获取天线检测指令的结果
        XHR.poll(2, "<%=controller%>admin/ACU_Antenna/getCalibrationReturn", null, function(x)
        {
            document.getElementById("testLog").value = x.responseText;                
        });
    }
	
    //在点击EnterCalibration之后,
    function EnterCalibration()
    {
		Refresh();
		document.getElementById("warmingCalibration").innerHTML = "";

        XHR1.post('<%=controller%>admin/ACU_Antenna/calibration', {token:'<%=token%>', step: '9'}, function(x){
            //如果进入测试模式成功
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warmingCalibration").innerHTML = "<%:Title:Enter calibration mode success!%>";
                document.getElementById("enter").disabled=false;
                document.getElementById("exit").disabled=false;
                document.getElementById("stopTest").disabled=false;
                document.getElementById("fullCali").disabled=false;
                document.getElementById("polLimit").disabled=false;
                document.getElementById("pitchLimit").disabled=false;
                document.getElementById("amuzithLimit").disabled=false;
                document.getElementById("rollLimit").disabled=false;
                document.getElementById("inertial").disabled=false;
                document.getElementById("pitchAngleLimit").disabled=false;
                document.getElementById("subOffset").disabled=false;
            }
            else
            {
                document.getElementById("warmingCalibration").innerHTML = "Title:" + x.responseText;
            }
        })
    }
    function ExitCalibration()
    {
		document.getElementById("warmingCalibration").innerHTML = "";
        XHR1.post('<%=controller%>admin/ACU_Antenna/calibration', {token:'<%=token%>', step: '10'}, function(x){
            //如果退出测试模式成功
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warmingCalibration").innerHTML = "<%:Title:Exit calibration mode success!%>";
                document.getElementById("enter").disabled=false;
                document.getElementById("exit").disabled=false;
                document.getElementById("stopTest").disabled=true;
                document.getElementById("fullCali").disabled=true;
                document.getElementById("polLimit").disabled=true;
                document.getElementById("pitchLimit").disabled=true;
                document.getElementById("amuzithLimit").disabled=true;
                document.getElementById("rollLimit").disabled=true;
                document.getElementById("inertial").disabled=true;
                document.getElementById("pitchAngleLimit").disabled=true;
                document.getElementById("subOffset").disabled=true;
            }
            else
            {
                document.getElementById("warmingCalibration").innerHTML = "Title:" + x.responseText;
            }
        })
    }
	
    function CalibrationIitems(var1)
    {
        XHR1.post('<%=controller%>admin/ACU_Antenna/calibration', {token:'<%=token%>', step: var1}, function(x){

            //停止全面测试
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warmingCalibration").innerHTML = "<%:Title: Operation success!%>";
            }
            else
            {
                document.getElementById("warmingCalibration").innerHTML = "Title:" + x.responseText;
            }
        })
    }


	
    function GetCalibrationInfo()
    {
        XHR1.post('<%=controller%>admin/ACU_Antenna/getTestInfo', {token:'<%=token%>', step: '1'}, function(x){
			
            
            //对返回的数据进行解析，并填入到相应的控件
            var str = x.responseText;
            //是否有错误警告
            if(str.match(/Error/g) == null)
            {
                var n = str.split(",");
                document.getElementById("polZero").innerHTML = n[2];
                document.getElementById("polLinearity").innerHTML = n[3];
                document.getElementById("leftAngle").innerHTML = n[4] + " &#176";
                document.getElementById("polRightAngle").innerHTML = n[5] + " &#176";
                document.getElementById("pitch90Zero").innerHTML = n[6];
                document.getElementById("pitchLinearity").innerHTML = n[7];
                document.getElementById("pitchUpSwitch").innerHTML = n[8] + " &#176";
                document.getElementById("pitchDownSwitch").innerHTML = n[9] + " &#176";
                document.getElementById("pitchUpLimit").innerHTML = n[10] + " &#176";
                document.getElementById("pitchDownLimit").innerHTML = n[11] + " &#176";
                document.getElementById("rollZero").innerHTML = n[12];
                document.getElementById("rollLinearity").innerHTML = n[13];
                document.getElementById("rollLeftSwitch").innerHTML = n[14] + " &#176";
                document.getElementById("rollRightSwitch").innerHTML = n[15] + " &#176";
                document.getElementById("rollLeftLimit").innerHTML = n[16] + " &#176";
                document.getElementById("rollRightLimit").innerHTML = n[17] + " &#176";
				document.getElementById("warmingCalibration").innerHTML = "Data:"+n[2]+","+n[3]+","+n[4]+","
				+n[5]+","+n[6]+","+n[7]+","+n[8]+","+n[9]+","+n[10]+","+n[11]+","+n[12]+","+n[13]+","+n[14]+","
				+n[15]+","+n[16]+","+n[17]+",0,0,0,0,0,0";				
                document.getElementById("setPolZero").value = n[2];
                document.getElementById("setPitchUp").value = n[10];
                document.getElementById("setRollZero").value = n[12];
                document.getElementById("setAzimuthBoard").value = 0;
                document.getElementById("setPitchInertial").value = 0;
                document.getElementById("setRollInertial").value = 0;
            }
            else
            {
                document.getElementById("warmingCalibration").innerHTML = "Title:" + str;
            }
        })
    }
    function ClearTestLog()
    {
        document.getElementById("testLog").value = "";
        //清空TestLogFile
        XHR1.post('<%=controller%>admin/ACU_Antenna/clearCalibrationReturn', {token:'<%=token%>'}, function(x){

        })
    }
    
    function SetAdjustAnt()
    {
		document.getElementById("warmingAdjust").innerHTML = "";
        var adjustAntData = new Object();
        adjustAntData.setPolZero = document.getElementById("setPolZero").value;
        adjustAntData.setPitchUp = document.getElementById("setPitchUp").value;
        adjustAntData.setRollZero = document.getElementById("setRollZero").value;
        adjustAntData.setAzimuthBoard = document.getElementById("setAzimuthBoard").value;
        adjustAntData.setPitchInertial = document.getElementById("setPitchInertial").value;
        adjustAntData.setRollInertial = document.getElementById("setRollInertial").value;

        //将WEB上输入的天线校准数据传送到后台
        XHR1.post('<%=controller%>admin/ACU_Antenna/setAdjustSet', {token:'<%=token%>', 
            para1: adjustAntData.setPolZero,
            para2: adjustAntData.setPitchUp,
            para3: adjustAntData.setRollZero,
            para4: adjustAntData.setAzimuthBoard,
            para5: adjustAntData.setPitchInertial,
            para6: adjustAntData.setRollInertial}, function(x){
            var str = x.responseText;
            //如果设置失败怎弹出告警框
            if(x.responseText.includes("COMMAND OK") == true)
            {
                document.getElementById("warmingAdjust").innerHTML = "<%:Title: Set Adjust Ant Success!%>";
            }
            else
            {
                document.getElementById("warmingAdjust").innerHTML = "Title:" + str;
            }
        })
    }
    function ClearAdjustAnt()
    {
        document.getElementById("setPolZero").value = "";
        document.getElementById("setPitchUp").value = "";
        document.getElementById("setRollZero").value = "";
        document.getElementById("setAzimuthBoard").value = "";
        document.getElementById("setPitchInertial").value = "";
        document.getElementById("setRollInertial").value = "";
    }

    </script>
    </head>
    <body onbeforeunload="return checkLeave()">
        <p style="color:red;" id="warmingCalibration"></p>
        <fieldset class="cbi-section">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Test Items%></h5>
                    <i class="icon" ></i>
                <div class="pull-right">
                    <div style="margin-top: 4px; margin-bottom: 0px;margin-right: 4px">		
                        <input class="btn btn-success" type="button" id="enter" value="<%:Enter Calibration%>" onclick="EnterCalibration()">
                        <i class="icon"></i>
                        <input class="btn btn-info" type="button" id="exit" value="<%:Exit Calibration%>" onclick="ExitCalibration()">
                        <i class="icon"></i>
                    </div>
                </div>
            </div>
            <div class="widget-content nopadding">
                <table width="100%" cellspacing="10">
                    <tr><td width="33%"><%:Stop Test%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="stopTest" value="<%:DONE%>" onclick="CalibrationIitems(0)">
                    </td></tr>			
                    <tr><td width="33%"><%:Full Calibration%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="fullCali" value="<%:DONE%>" onclick="CalibrationIitems(1)">
                    </td></tr>									
                    <tr><td width="33%"><%:Pol Limit%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="polLimit" value="<%:DONE%>" onclick="CalibrationIitems(2)">
                    </td></tr>	
                    <tr><td width="33%"><%:Pitch Limit%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="pitchLimit" value="<%:DONE%>" onclick="CalibrationIitems(3)">
                    </td></tr>
                    <tr><td width="33%"><%:Amuzith Limit%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="amuzithLimit" value="<%:DONE%>" onclick="CalibrationIitems(4)">
                    </td></tr>
                    <tr><td width="33%"><%:Roll Limit%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="rollLimit" value="<%:DONE%>" onclick="CalibrationIitems(5)">
                    </td></tr>
                    <tr><td width="33%"><%:Inertial%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="inertial" value="<%:DONE%>" onclick="CalibrationIitems(6)">
                    </td></tr>
                    <tr><td width="33%"><%:Pitch Angle Limit%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="pitchAngleLimit" value="<%:DONE%>" onclick="CalibrationIitems(7)">
                    </td></tr>
                    <tr><td width="33%"><%:Sub Offset%></td><td>
                    <input class="btn" type="button" disabled="disabled" id="subOffset" value="<%:DONE%>"  onclick="CalibrationIitems(8)">
                    </td></tr>
                </table>
            </div>
        </div>
        </fieldset>
		

        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Test Log%></h5>
                    <i class="icon" ></i>
                <div class="pull-right">
                    <div style="margin-top: 4px; margin-bottom: 0px;margin-right: 4px">		
                        <input class="btn btn-success" type="button" id="clearTestLog" value="<%:Clear Log%>" onclick="ClearTestLog()">
                        <i class="icon"></i>
                    </div>
                </div>
            </div>
            <div class="widget-content nopadding">
                <div>
                <textarea style="width:100%" readonly="readonly" cols="100" rows="20" id="testLog">
                </textarea>
                </div>
            </div>
        </div>

		
        <p style="color:red;" id="warmingAdjust"></p>
        <fieldset class="cbi-section">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Adjust Ant%></h5>
                <div class="pull-right">
                    <div style="margin-top: 4px; margin-bottom: 0px;margin-right:10px">
                    <input class="btn btn-success" type="button" value="<%:Set Adjust Ant%>" onclick="SetAdjustAnt()">
                    <input class="btn btn-primary" type="button" value="<%:Clear Adjust Ant%>" onclick="ClearAdjustAnt()">
                    <i class="icon"></i>
                    </div>
                    </div>
            </div>
            <div class="widget-content nopadding">
                <table width="100%" cellspacing="10">
                    <tr><td width="15%"><%:Set Pol Zero%></td><td><input id="setPolZero" type="number" min="-15" max="15" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                            <span class="cbi-value-helpicon">
                            <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                            </span>
                            <%:Range%>:-15.00~15.00
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Set Pitch Up%></td><td><input id="setPitchUp" type="number" min="90" max="130" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                            <span class="cbi-value-helpicon">
                            <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                            </span>
                            <%:Range%>:90.00~130.00&#176
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Set Roll Zero%></td><td><input id="setRollZero" type="number" min="-15" max="15" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                        <span class="cbi-value-helpicon">
                            <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                        </span>
                        <%:Range%>:-15.00~15.00
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Set Azimuth Board%></td><td><input id="setAzimuthBoard" type="number" min="-180" max="180" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                        <span class="cbi-value-helpicon">
                        <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                        </span>
                        <%:Range%>:-180.00~180.00&#176
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Set Pitch Inertial%></td><td><input id="setPitchInertial" type="number" min="-3" max="3" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                        <span class="cbi-value-helpicon">
                        <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                        </span>
                        <%:Range%>:-3.00~3.00&#176
                        </div>
                    </td></tr>
                    <tr><td width="15%"><%:Set Roll Inertial%></td><td><input id="setRollInertial" type="number" min="-3" max="3" class="cbi-input-text"/>
                        <div class="cbi-value-description">
                        <span class="cbi-value-helpicon">
                        <img src="/luci-static/resources/cbi/help.gif" alt="help" />
                        </span>
                        <%:Range%>:-3.00~3.00&#176
                        </div>
                    </td></tr>
                </table>
            </div>
        </div>
        </fieldset>	
		
        <fieldset class="cbi-section">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                <i class="icon-align-justify"></i>
                </span>
                <h5><%:Test Info%></h5>
                <div class="pull-right">
                    <div style="margin-top: 4px; margin-bottom: 0px;margin-right:10px">
                    <input class="btn btn-primary" type="button" value="<%:Get Test Info%>" onclick="GetCalibrationInfo()">
                    <i class="icon" ></i>
                    </div>
                </div>
            </div>
            <div class="widget-content nopadding">
                <table width="100%" cellspacing="10">
                    <tr><td width="33%"><%:Pol Zero%></td><td id="polZero"></td></tr>
                    <tr><td width="33%"><%:Pol Linearity%></td><td id="polLinearity"></td></tr>
                    <tr><td width="33%"><%:Pol Left Angle%></td><td id="leftAngle"></td></tr>
                    <tr><td width="33%"><%:Pol right Angle%></td><td id="polRightAngle"></td></tr>											
                    <tr><td width="33%"><%:Pitch 90 Zero%></td><td id="pitch90Zero"></td></tr>	
                    <tr><td width="33%"><%:Pitch Linearity%></td><td id="pitchLinearity"></td></tr>
                    <tr><td width="33%"><%:Pitch Up Switch%></td><td id="pitchUpSwitch"></td></tr>
                    <tr><td width="33%"><%:Pitch Down Switch%></td><td id="pitchDownSwitch"></td></tr>
                    <tr><td width="33%"><%:Pitch Up Limit%></td><td id="pitchUpLimit"></td></tr>
                    <tr><td width="33%"><%:Pitch Down Limit%></td><td id="pitchDownLimit"></td></tr>
                    <tr><td width="33%"><%:Roll Zero%></td><td id="rollZero"></td></tr>
                    <tr><td width="33%"><%:Roll Linearity%></td><td id="rollLinearity"></td></tr>											
                    <tr><td width="33%"><%:Roll Left Switch%></td><td id="rollLeftSwitch"></td></tr>	
                    <tr><td width="33%"><%:Roll Right Switch%></td><td id="rollRightSwitch"></td></tr>
                    <tr><td width="33%"><%:Roll Left Limit%></td><td id="rollLeftLimit"></td></tr>
                    <tr><td width="33%"><%:Roll Right Limit%></td><td id="rollRightLimit"></td></tr>
                </table>
            </div>
        </div>
        </fieldset>

    </body>
</html>
<%+footer%>